package cn.anecansaitin.whimsy.common.register;

import cn.anecansaitin.whimsy.Whimsy;
import cn.anecansaitin.whimsy.common.block.RockAltar;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredRegister;

import java.util.function.Supplier;

public class ModBlocks {
    public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(Registries.BLOCK, Whimsy.MODID);

    public static final DeferredHolder<Block, ? extends RockAltar> ROCK_ALTAR = register("rock_altar", RockAltar::new);

    public static <T extends Block> DeferredHolder<Block, ? extends T> register(String name, Supplier<? extends T> sup) {
        DeferredHolder<Block, ? extends T> register = BLOCKS.register(name, sup);
        ModItems.ITEMS.register(name, () -> new BlockItem(register.get(), new Item.Properties()));
        return register;
    }
}
